<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Users extends CI_Controller {
     function __construct(){
        parent::__construct();
        $this->load->model('usuarios_m');
      }

//Comprobar usuario existente
      public function validate_user(){
          $username = $this->input->post('username',TRUE);
          $userpass = $this->input->post('userpass',TRUE);
          
          $login = $this->usuarios_m->validate_user($username,$userpass);
          if ($login == TRUE){
              $datos_session = array(
                  'is_logued_in'=>TRUE,
                  );
              
          $this->session->set_userdata($datos_session);
          redirect('administrar');
          }else{
              redirect('login'); 
           }
      }
          
//Salida del sistema         
      public function logout(){
          $this->session->unset_userdata(array('is_logued_in'));
          $this->session->sess_destroy();
          redirect('login');            
      }
          
    
}